<template>
  <div class="app-container">
    <avue-form
      ref="formref"
      :key="formkey"
      :option="option"
      v-model="form"
      @submit="handleSubmit"
    ></avue-form>
  </div>
</template>

<script>
// import { v_phone, v_cardid } from '@/utils/validate'

export default {
  data() {
    return {
      formkey: 1,
      form: {},
      option: {
        column: [
          {
            type: 'input',
            label: '上级名称',
            span: 8,
            display: true,
            prop: 'parentName',
            readonly: true,
          },
          {
            type: 'input',
            label: '单元名称',
            span: 8,
            display: true,
            prop: 'name',
            rules: [
              {
                required: true,
                message: '单元名称必须填写',
              },
            ],
            required: true,
          },
          {
            type: 'number',
            label: '楼层数量',
            controls: true,
            span: 8,
            display: true,
            prop: 'floorNumbers',
            minRows: 1,
            maxRows: 33,
            precision: 0,
            required: true,
            rules: [
              {
                required: true,
                message: '楼层数量必须填写',
              },
            ],
            value: '1',
          },
          {
            type: 'number',
            label: '每层户数',
            controls: true,
            span: 8,
            display: true,
            prop: 'roomNumbers',
            minRows: 1,
            maxRows: 10,
            precision: 0,
            required: true,
            rules: [
              {
                required: true,
                message: '每层户数必须填写',
              },
            ],
            value: '1',
          },
        ],
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 140,
        gutter: 0,
        menuBtn: true,
        submitBtn: true,
        submitText: '提交',
        emptyBtn: false,
        emptyText: '清空',
        menuPosition: 'center',
      },
    };
  },
  created() {},
  methods: {
    get_detail() {
      getNotice().then((res) => {
        const data = res.data;
        this.form = data;
      });
    },

    handleSubmit(form, done) {
      this.saveSet(submit, form, done);
    },
    saveSet(Interface, params, done) {
      Interface(params).then(
        (res) => {
          done();
          this.$message({
            type: 'success',
            message: res.msg,
          });
        },
        (error) => {
          done();
          window.console.log(error);
        },
      );
    },
  },
};
</script>
